const path=require("path"),fs=require("fs"),Launch=require(path.join(__dirname,"/Launch.bundle")),{rpath}=require(path.join(__dirname,"/config.bundle"));let $=require(path.join(__dirname,"/config.bundle"));module.exports=function(){document.querySelector(".apply__danger-pop").addEventListener("click",function(){$.db.length=0,$.files_.length=0,$.tmpf_={},$.config={},$.size=0,$._fs.cleanActiveList(),$._fs.cleanBase(),fs.writeFileSync(path.join(__dirname,rpath.db),JSON.stringify($.db)),fs.writeFileSync(path.join(__dirname,rpath.config),JSON.stringify({theme:"dark",lang:"ru",FileDeleteNotice:1,PresetDeleteNotice:1,ReadSubfolders:1,ActivePreset:"start"})),document.querySelector(".delpreset__from-pop").style.display="none",document.querySelector(".delpreset__from-container").style.display="none",Launch()}),document.querySelector("#global__change").addEventListener("change",function(){this.checked||(this.removeAttribute("checked"),this.checked=!1,$.config.ReadSubfolders=0,$._fs.setReadSubfolders(0)),this.checked&&(this.setAttribute("checked","true"),this.checked=!0,$.config.ReadSubfolders=1,$._fs.setReadSubfolders(1)),fs.writeFileSync(path.join(__dirname,rpath.config),JSON.stringify($.config))}),document.querySelector(".update__files").addEventListener("click",function(){document.querySelector("#preset-id").value="",document.querySelector("#change-name").value="",document.querySelector("#change-from").value="",document.querySelector("#change-to").value="",document.querySelector("#change-file").value="",document.querySelector("#change-name-from").value="",document.querySelector("#change-name-to").value="",document.querySelector("#change-size").value="",$.files_=[],$._fs.cleanActiveList(),document.querySelector(".global__button-danger").style.display="none",document.querySelector(".need__block > div").innerHTML="",document.querySelector(".check__all").removeAttribute("checked"),document.querySelector(".check__all").checked=!1,document.querySelector(".global__button-tran").style.display="none",document.querySelector(".file__tbody").innerHTML=`
            <div class="loader">
                <div class="sk-circle-bounce">
                    <div class="loading-chat">
                        <svg class="spinner" viewBox="0 0 50 50">
                            <circle class="path" cx="25" cy="25" r="20" fill="none" stroke-width="5"></circle>
                        </svg>
                    </div>
                </div>
            </div>`,setTimeout(()=>{document.querySelector(".loader").style.display="none",$._fs.updatePath()},300)}),document.querySelector(".search__apply").addEventListener("click",function(){const a=document.querySelector("#global__search"),b=document.querySelector("#sort__column"),c=document.querySelector("#sort__type");document.querySelector(".check__all").checked=!1,document.querySelector(".check__all").setAttribute("checked",""),document.querySelector(".search__popup").style.display="none",document.querySelector(".search__button-span").classList.remove("tb__bth-active"),$._fs.searchFiles(a.value,+b.value,+c.value)}),document.querySelector(".new__apply").addEventListener("click",function(){const a=document.querySelector("#sort__column"),b=document.querySelector("#sort__type");document.querySelector(".check__all").checked=!1,document.querySelector(".check__all").setAttribute("checked",""),document.querySelector(".new__popup").style.display="none",document.querySelector(".new__button-span").classList.remove("tb__bth-active"),$._fs.sortFiles(+a.value,+b.value)})};
